
export const getListData =(data)=>{
	return{
		type:'GETLISTS',
		data
	}
}

export function fetchList() {
	return dispatch=>{
		var url= `http://localhost:3000/news/list`;
		return fetch(url,
			{
				method:"post"
			})
			.then(res=>{
				return res.json();
			})
			.then(data=>{
				dispatch(getListData(data));
			})
	}
}

export const getListProduct =(data)=>{
	return{
		type:'GETPRODUCT',
		data
	}
}

export function fetchProduct() {
	return dispatch=>{
		var url= `http://localhost:3000/product/list`;
		return fetch(url,
			{
				method:"post"
			})
			.then(res=>{
				return res.json();
			})
			.then(data=>{
				dispatch(getListProduct(data));
			})
	}
}